package ui;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Font;
import java.util.ArrayList;

import javax.swing.JLabel;
import javax.swing.JPanel;

import model.Renter;
import model.RenterStatus;
import ui.ItemList;
import control.CtrRenter;

public class WaitinglistPanel extends ItemList{

	//private ArrayList<String> fullName;
//	private ArrayList<String> email;
//	private ArrayList<String> pPhone;
//	private ArrayList<String> mPhone;
	private CtrRenter r;
	private ArrayList<Renter> allRenters;
	public WaitinglistPanel(String name, int sizePctY) {
		
		super(name, sizePctY);
		r = new CtrRenter();
		allRenters = r.getAll();
		// items
//					items = new ArrayList<String>();
//					items.add("H.C. Andersen");
//					items.add("Thor");
//					items.add("Odin");
//					items.add("Michael Jackson");
//					items.add("Einstein");
//					items.add("Helle Thorning");
//					
					//end items
//		fullName = new ArrayList<String>();
//		email = new ArrayList<String>();
//		pPhone = new ArrayList<String>();
//		mPhone = new ArrayList<String>();
//		System.out.println(r.getAll().get(0).getLastName());
//
//		for (Renter renter:allRenters){
//			if(renter.getStatus() == RenterStatus.WAITING){
//				fullName.add(renter.getFirstName()+renter.getLastName());
//				email.add(renter.getEmail());
//				mPhone.add(renter.getMobilePhone());
//				pPhone.add(renter.getPrivatePhone());
//			}
//		}
//			int i=0;
//			for(String item:fullName){
//				System.out.println("Waiting List For Loaded");
//				newPanel(item,email.get(i),mPhone.get(i),pPhone.get(i));
//				i++;
//			}
			for(Renter r:allRenters)
			{
				if(r.getStatus()==RenterStatus.WAITING)
				{
					String fullName = r.getFirstName()+" "+r.getLastName();
					newPanel(fullName,r.getEmail(),r.getMobilePhone(),r.getPrivatePhone());
				}
			}
		

	}
	@Override
	protected void setPanels(JPanel panel, String item1,String item2, String item3, String item4){
		System.out.println("Waiting List Panels Loaded");
		
		Font font = new Font("Segoe UI Black", Font.BOLD,20);
		Font font2 = new Font("Segoe UI Black", Font.BOLD,12);
		
		JLabel label1 = new JLabel("A: "+item1);
		label1.setFont(font);
		
		JLabel label2 = new JLabel("<html>Email: "+item2+"<br>MobilePhone: "+item3+"<br>PrivatePhone: "+item4+"</html>");
		label2.setFont(font2);
		

		panel.add(label1,BorderLayout.CENTER);
        panel.add(new WaitinglistButtons(Color.RED),BorderLayout.LINE_END);
        panel.add(label2,BorderLayout.PAGE_END);
        
	}
}